
bool isSameTree(struct TreeNode* p, struct TreeNode* q) {
    if (p == NULL && q == NULL)return true;
    if (p == NULL || q == NULL)return false;
    if (p->val != q->val)return false;
    return isSameTree(p->left, q->left) && isSameTree(p->right, q->right);
}

bool resolution(struct TreeNode* root1, struct TreeNode* root2)
{
    if (root1 == NULL && root2 == NULL)return true;
    else if (root1 == NULL || root2 == NULL)return false;
    else if (root1->val != root2->val)return false;
    return resolution(root1->left, root2->right) && resolution(root1->right, root2->left);
}

bool isSymmetric(struct TreeNode* root) {
    return resolution(root->left, root->right);
}